package com.ruoyi.demo.domain.wrapper.query;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.demo.domain.dao.DemoUser;
import com.ruoyi.demo.domain.query.DemoUserQo;

/**
 * 人员查询条件包装
 *
 * @author 尹国春
 * @date 2022-02-25
 */
public class DemoUserWrapperQ {

    public static LambdaQueryWrapper<DemoUser> getQueryWrapper(DemoUserQo entity){
        LambdaQueryWrapper<DemoUser> wrapper= getQueryWrapper((DemoUser)entity);
        if(entity.getBeginUpdateTime()!=null){
            wrapper.gt(DemoUser::getUpdateTime,entity.getBeginUpdateTime());
        }
        if(entity.getEndUpdateTime()!=null){
            wrapper.lt(DemoUser::getUpdateTime,entity.getEndUpdateTime());
        }
        return wrapper;
    }

    public static LambdaQueryWrapper<DemoUser> getQueryWrapper(DemoUser entity){
        LambdaQueryWrapper<DemoUser> wrapper= Wrappers.<DemoUser>lambdaQuery();
        if(entity.getUserId()!=null && entity.getUserId().trim().length()>0){
            wrapper.eq(DemoUser::getUserId,entity.getUserId());
        }
        if(entity.getDeptId()!=null && entity.getDeptId().trim().length()>0){
            wrapper.eq(DemoUser::getDeptId,entity.getDeptId());
        }
        if(entity.getUserName()!=null && entity.getUserName().trim().length()>0){
            wrapper.eq(DemoUser::getUserName,entity.getUserName());
        }
        if(entity.getState()!=null && entity.getState().trim().length()>0){
            wrapper.eq(DemoUser::getState,entity.getState());
        }
        if(entity.getCreateTime()!=null){
            wrapper.eq(DemoUser::getCreateTime,entity.getCreateTime());
        }
        if(entity.getCreateBy()!=null && entity.getCreateBy().trim().length()>0){
            wrapper.eq(DemoUser::getCreateBy,entity.getCreateBy());
        }
        if(entity.getUpdateTime()!=null){
            wrapper.eq(DemoUser::getUpdateTime,entity.getUpdateTime());
        }
        if(entity.getUpdateBy()!=null && entity.getUpdateBy().trim().length()>0){
            wrapper.eq(DemoUser::getUpdateBy,entity.getUpdateBy());
        }
        if(entity.getDelFlag()!=null){
            wrapper.eq(DemoUser::getDelFlag,entity.getDelFlag());
        }
        return wrapper;
    }
}